<template>
	<view class="">
		<u-navbar :title="$t('白嫖盒子')"></u-navbar>
		<view class="content_view" v-if="userLuckyMh && userLuckyMh.open == 1">
			<view class="day">
				<view class="dayIiem" :class="{ dayIiemActive: weekday === 1 }">{{$t('周一')}}</view>
				<view class="dayIiem" :class="{ dayIiemActive: weekday === 2 }">{{$t('周二')}}</view>
				<view class="dayIiem" :class="{ dayIiemActive: weekday === 3 }">{{$t('周三')}}</view>
				<view class="dayIiem" :class="{ dayIiemActive: weekday === 4 }">{{$t('周四')}}</view>
				<view class="dayIiem" :class="{ dayIiemActive: weekday === 5 }">{{$t('周五')}}</view>
				<view class="dayIiem" :class="{ dayIiemActive: weekday === 6 }">{{$t('周六')}}</view>
				<view class="dayIiem" :class="{ dayIiemActive: weekday === 7 }">{{$t('周日')}}</view>
			</view>
			<view class="button" @click="lookbox(userLuckyMh.blindbox_id, 7)">
				<view class="baipiaoBox">
					<!--   -->
					<!-- <view class="xiangouBox-1">已购0/{{userLuckyMh.source_info.lucky_buy_num_limit}}次</view> -->
				</view>
				<view class="button-0">
					{{$t('¥')}}
					<text>0</text>
				</view>
				<!-- <view class="button-0">{{$t('¥')}}<text>{{ floatInt(userLuckyMh.blindbox_info.price, 0) }}</text></view> -->
				<view class="button-1">{{ userLuckyMh.blindbox_info.xiaoliang || 0 }}{{$t('人喜欢')}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userLuckyMh: null,
				weekday: 9
			};
		},
		onLoad() {
			const today = new Date().getDay(); // 获取今天是一周中的第几天（0-6）
			this.weekday = today === 0 ? 7 : today;
		},
		onShow() {
			this.getNewPeopleList();
		},
		onShow() {
			if (uni.getStorageSync("user")) {
				this.getList()
			} else {
				uni.redirectTo({
					url:'/pages/my/login'
				})
			}
		},
		methods: {
			/* 字符串转小数 */
			floatInt(val, length = 1) {
				let f = parseFloat(val);
				let result = f.toFixed(length);
				return result;
			},
			/* 获取首页活动盲盒列表 */
			getNewPeopleList() {
				this.$http({
					url: '/api/common/get_new_user_buy_open'
				}).then((res) => {
					// this.xinrenMh = res.data.data.xinren;
					// this.presentMh = res.data.data.present;
					this.userLuckyMh = res.data.data.user_lucky;
					console.log(this.userLuckyMh, 'userLuckyMh');
				});
			},
			// 查看盲盒
			lookbox(id) {
				uni.navigateTo({
					url: '/pages/home/kaixiang?id=' + id  + '&boxSource=' + 7
				});
			},
			// 前往旧的
		}
	};
</script>

<style lang="scss" scoped>
	.content_view {
		width: 750rpx;
		height: 1622rpx;
		background-image: url('../../../static/image/enimg/baipiao.png');
		background-size: 100% 100%;
		position: relative;
		.day {
			position: absolute;
			width: 660rpx;
			height: 46rpx;
			// background-color: red;
			display: flex;
			top: 520rpx;
			left: 50%;
			margin-left: -330rpx;
			justify-content: space-between;
			color: #eab79b;
			font-size: 24rpx;
			align-items: center;
			.dayIiem {
				padding: 4rpx 20rpx;
			}
			.dayIiemActive {
				background-color: #fefdfc;
				color: #000;
			}
		}
		.button {
			position: absolute;
			width: 300rpx;
			height: 100rpx;
			// background-color: #f5d066;
			background-image: url('../../../static/image/enimg/O1CN011i0r0R2JfEvh9rrD4___2215984279448.png');
			background-size: 100% 100%;
			top: 820rpx;
			left: 340rpx;
			padding: 10rpx;
			padding-left: 20rpx;
			box-sizing: border-box;
			.button-0 {
				color: #ea9f58;
				font-size: 24rpx;
				font-weight: bold;
				text {
					font-size: 40rpx;
				}
			}
			.button-1 {
				color: #ea9f58;
				font-size: 22rpx;
				font-weight: 4000;
			}
		}
	}
	.xiangouBox-0 {
		top: 0;
		font-size: 34rpx;
		text {
			font-size: 38rpx;
			font-weight: bold;
			padding: 0 4rpx;
			line-height: 38rpx;
			height: 38rpx;
		}
	}
</style>
